# Makefile for fish pro

IDIR = include
FLAGS = -g -I$(IDIR)
#LM = -lm
#SRVFLAGS = -lsqlite3 -pthread
OBJSERVER = server.o 
OBJCLIENT = client.o cl.o scanadt.o strlib.o genlib.o exception.o random.o
SVNAME = hdbserver
CLNAME = hdb

#DBFILE = proto.db

# Rules for the main objective
all: client server
	@ echo Compiling...
	@ mkdir -p obj
	@ echo Moving all objects to obj directory...
	@ mv *.o ./obj
	@ echo Execute "make clean" to remove all objects	


client:  $(OBJCLIENT)
	@ echo Compiling dependencies for the client...
	 $(CC) $(OBJCLIENT) -o $(CLNAME)

server:  $(OBJSERVER)
	@ echo Compiling dependencies for the server...
	 $(CC) $(OBJSERVER) -o $(SVNAME)
	 
# Rules for secondary objectives

client.o: ./client/client.c
	@ $(CC) -c $(FLAGS) $?
	
server.o: ./server/server.c
	@ $(CC) -c $(FLAGS) $?
	
cl.o: ./client/cl.c
	@ $(CC) -c $(FLAGS) $?

scanadt.o: ./scanADT/scanadt.c
	@ $(CC) -c $(FLAGS) $?

strlib.o: ./scanADT/strlib.c
	@ $(CC) -c $(FLAGS) $?
	
genlib.o: ./scanADT/genlib.c
	@ $(CC) -c $(FLAGS) $?

exception.o: ./scanADT/exception.c
	@ $(CC) -c $(FLAGS) $?
	
random.o: ./scanADT/random.c
	@ $(CC) -c $(FLAGS) $?
		
	
# Generate the binaries, and put everything where it belongs
clean: all
	@ echo Deleting objects...
	@ rm ./obj/*.o
	@ rm requests.txt rooms.db answers.txt
